package com.goldcn.order.dao;

import com.goldcn.order.dto.*;
import com.goldcn.order.model.*;
import com.goldcn.order.vo.*;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface OrderInfoMapper {
    int deleteByPrimaryKey(Long orderID);

    int insert(OrderInfo record);

    int insertSelective(OrderInfo record);

    OrderInfo selectByPrimaryKey(Long orderID);

    int updateByPrimaryKeySelective(OrderInfo record);

    int updateByPrimaryKey(OrderInfo record);

    int updateAmountByPrimaryKey(Map<String, Object> param);

    int updatePayNoByPrimaryKey(Map<String, Object> param);

    int updateStateByPrimaryKey(OrderStateDto orderStateDto);

    List<OrderInfo> selectListByConditon(OrderSelectDto selectDto);

    //1待付款 指定商品  指定时间
    List<OrderInfo> selectListByConditon2(OrderSelectDto selectDto);

    List<OrderSettlement> selectSettlement(SettlementSelectDto selectDto);

    List<OrderBankSettlement> selectBranchBankSettle(SettlementSelectDto selectDto);

    List<OrderInfo> selectByPayNo(String payNo);

    List<OrderAndItem> selectOrderAndItemList(SettlementSelectDto selectDto);

    List<OrderAndItem> selectOrderAndItemListPage(List<String> list);

    List<String> selectOrderIdAndItemList(SettlementSelectDto selectDto);

    SupplierTradingTipsVo selectSupplierTradingTips(Long sellerID);

    OrderCountVo selectOrderCount(OrderCountDto countDto);

    OrderCountVo selectOrderAmountCount(OrderCountDto countDto);

    List<OrderCountMoreVo> selectByPaterIDList(List<Long> salesIDList);

    List<OrderCountMoreVo> selectCountByManagerID(Map<String, Object> params);


    String selectLatestInvoicesByUserID(Long userID);

    Map selectLatestInvoicesByUserIDV2(Long userID);

    Map<String, Integer> selectTipsByUserID(Long userID);

    List<String> selectPayNoByNopaind(@Param("startTime") Long startTime, @Param("endTime") Long endTime);

    List<Long> selectAllID();

    BigDecimal selectTotalCommission(@Param("branchID") Long branchID, @Param("companyID") Long companyID);

    BigDecimal selectTotalEmployeeCommission(@Param("branchID") Long branchID, @Param("companyID") Long companyID);

    List<OrderAndItem> selectOrderItemBySelf(OrderItemSelfDto selfDto);

    List<DetailListVo> selectDetailList(OrderItemSelfDto selfDto);

    //create by zll 2017/4/8
//分部数据
    List<BranchReportVo> reportHeader(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> reportHeaderTwo(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> reportHeaderThir(BranchReportFormDto branchReportFormDto);

    //支部数据
    List<BranchReportVo> reportHeadquarters(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> reportBranch(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> reportTwoLevelBranchID(BranchReportFormDto branchReportFormDto);


    //员工销售
    List<MemberSalesVo> memberSalesCountsHeaders(MemberReportDto memberReportDto);

    List<MemberSalesVo> memberSalesCountsBranch(MemberReportDto memberReportDt);

    List<MemberSalesVo> memberSalesCountsTwoLevel(MemberReportDto memberReportDt);

    List<MemberSalesVo> memberSalesCountsSubbranchID(MemberReportDto memberReportDt);

    //商品销售数据
    //part one
    List<BranchReportVo> reportHeaderGoods(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> reportHeaderTwoGoods(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> reportHeaderThirGoods(BranchReportFormDto branchReportFormDto);

    //part two
    List<BranchReportVo> reportHeadquartersGoods(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> reportBranchGoods(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> reportTwoLevelBranchIDGoods(BranchReportFormDto branchReportFormDto);

    //part three
    List<MemberSalesVo> memberSalesCountsHeadersGoods(MemberReportDto memberReportDto);

    List<MemberSalesVo> memberSalesCountsBranchGoods(MemberReportDto memberReportDt);

    List<MemberSalesVo> memberSalesCountsTwoLevelGoods(MemberReportDto memberReportDt);

    List<MemberSalesVo> memberSalesCountsSubbranchIDGoods(MemberReportDto memberReportDt);


    //得到销售总额和数量
    Map<String, Object> getAllCounts(BranchReportFormDto branchReportFormDto);


    List<Long> getAllUserAddress();

    List<OrderInfo> getOrderInfoNoAddress();

    //部门销售经理统计
    List<MemberSalesVo> selectSelfSalesOrder(BranchReportFormDto branchReportFormDto);


    // 对于本部的销售统计 -->直接属于本部的会员的销售统计
    List<MemberSalesVo> selectSelfSalesMemberOrder(BranchReportFormDto branchReportFormDto);

    //对于某个商品的 部门销售经理统计-->本部
    List<MemberSalesVo> memberSalesCountsHeadersGoodsSelf(MemberReportDto memberReportDto);

    //对于本部的
    List<MemberSalesVo> memberSalesCountsHeadersGoodsMember(MemberReportDto memberReportDto);

    List<MemberSalesVo> memberSalesCountsHeadersDirect(MemberReportDto memberReportDto);


    int updatePointTwoMinters();

    List<OrderInfo> getOldOrderInfo();

    List<OrderInfo> getOldThrOrderInfo();

    /**
     * 导出订单明细Demo
     *
     * @param params
     * @return
     */
    List<Map<String, String>> exportOrderDetail(Map<String, String> params);

    /**
     * 导出对账订单明细
     *
     * @param exportDto
     * @return
     */
    List<OrderAndItem> orderDetailForExport(OrderExportDto exportDto);

    List<MemberSalesVo> memberGoodsSalesById(MemberReportDto memberReportDto);

    List<MemberSalesVo> memberOrderSalesById(MemberReportDto memberReportDto);

    List<OrderInfo> selectOrderInfoBySelf(OrderItemSelfDto selfDto);


    /**
     * 会员销售数据
     *
     * @return
     */
    Long memberSalleCount(@Param("roleType") Integer roleType,
                          @Param("organizationalId") Long organizationalId,
                          @Param("salesManagerID") Long salesManagerID,
                          @Param("startTime") Long startTime,
                          @Param("endTime") Long endTime);


    /**
     * 员工销售数据
     *
     * @return
     */
    Long employeeSalleCount(@Param("roleType") Integer roleType,
                            @Param("organizationalId") Long organizationalId,
                            @Param("salesManagerID") Long salesManagerID,
                            @Param("startTime") Long startTime,
                            @Param("endTime") Long endTime,
                            @Param(value = "companyID") Long companyID);

    /**
     * 总部员工销售数
     *
     * @return
     */
    Long heardEmployeeSalleCount(@Param("startTime") Long startTime,
                                 @Param("endTime") Long endTime,
                                 @Param("topDeptID") Long topDeptID);

    /**
     * 总销售统计
     *
     * @param roleType
     * @param organizationalId
     * @return
     */
    Map<String, Object> totalSalleCount(@Param("roleType") Integer roleType,
                                        @Param("organizationalId") Long organizationalId,
                                        @Param("salesManagerID") Long salesManagerID,
                                        @Param("startTime") Long startTime,
                                        @Param("endTime") Long endTime,
                                        @Param(value = "companyID") Long companyID);

    /**
     * 总部员工
     *
     * @param branchReportFormDto
     * @return
     */
    List<MemberSalesVo> heardEmployee(BranchReportFormDto branchReportFormDto);


    /**
     * 会员统计
     *
     * @param memberReportDt
     * @return
     */
    List<MemberSalesVo> memberCount(MemberReportDto memberReportDt);


    List<OrderInfo> selectYesterDayOrderUser(Map<String, Object> map);

    List<String> selectOrderPresentID(Map<String, Object> map);

    List<OrderInfo> selectByIdList(List<Long> list);

    int deleteByList(List<Long> list);

    Map<String, Object> selectOrderSummery(Map<String, Object> map);

    /**
     * 列表首页统计特殊处理
     *
     * @return
     */
    Map<String, Object> heardEmpMemberTop(@Param(value = "companyID") Long companyID);

    List<BranchReportVo> empMemberTop(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> empMemberTop_2(BranchReportFormDto branchReportFormDto);

    List<BranchReportVo> empMemberTop_3(BranchReportFormDto branchReportFormDto);

    Long getEmployeeActNum(@Param("organizationalId") Long organizationalId);


    List<BranchReportVo> empMemberTopV2(BranchReportFormDto branchReportFormDto);

    List memberSalesCountsV2(MemberReportDto memberReportDto);

    List memberSalesCountsV3(MemberReportDto memberReportDto);

    List getBranchEmployee(BranchReportFormDto branchReportFormDto);

    List getBranchMember(BranchReportFormDto branchReportFormDto);

    List getMemberCountCount(MemberReportDto memberReportDto);

    int updateOrderStateOffline(String date);

    List<OrderInfo> selectOrderStateOffline(String date);

    Double selAmountByPayNo(@Param(value = "payNo") String payNo);

    //员工中收
    BigDecimal selectUserTotalCommission(Long userID);

    List<Map<String, Object>> selectUserCommissions(@Param("userID") Long userID, @Param("databaseTable") String databaseTable);

    List<OrderSupplierSettlement> selectSupplierSettlement(SupplierSettlementSelectDto selectDto);

    List<Map<String, Object>> supplierSettlementGroupByDate(SupplierSettlementSelectDetailDto selectDetailDto);

    List<SupplierSettlementOrderDto> supplierSettlementOrderInfo(SupplierSettlementSelectDetailDto selectDto);

    Map supplierSettlementOrderTotal(SupplierSettlementSelectDetailDto selectDto);

    List<OrderInfo> selectDeptRecord(@Param("oID") Long oID, @Param("level") Integer level, @Param("startTime") Long startTime,
                                     @Param("endTime") Long endTime, @Param("companyID") Long companyID);


}